<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>会员信息</title>
	<jsp:include page="../../util/import.jsp"/>
	<script type="text/javascript">
        $(function(){
            var $tt= $("#tt").bootstrapTable({
                url: '${basePath}/back/customer/listCustomer.sjson ',         	/**请求后台的URL（*）**/
                method: 'post',                       	/**请求方式（*）**/
                contentType: "application/x-www-form-urlencoded",
                dataType: 'json',
                toolbar: '#toolbar',               	    /**工具按钮用哪个容器**/
                striped: true,                      	/**是否显示行间隔色**/
                cache: false,                       	/**是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）**/
                pagination: true,                   	/**是否显示分页（*）**/
                sortable: false,                    	/**是否启用排序**/
                sortOrder: 'asc',                   	/**排序方式**/
                queryParamsType: '',
                sidePagination: 'server',           	/**分页方式：client客户端分页，server服务端分页（*）**/
                pageNumber: 1,
                pageSize:10,							/**初始化加载第一页，默认第一页**/
                pageList: [5,10, 25, 50],        	    /**可供选择的每页的行数（*）**/
                search: false,                       	/**是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大**/
                strictSearch: true,
                showColumns: true,                  	/**是否显示所有的列**/
                showRefresh: true,                  	/**是否显示刷新按钮**/
                minimumCountColumns: 2,             	/**最少允许的列数**/
                clickToSelect: true,                	/**是否启用点击选中行**/
                uniqueId: 'customerId',                 /**每一行的唯一标识，一般为主键列**/
                singleSelect  : true,                   /** 单选checkbox**/
                showToggle:false,                    	/**是否显示详细视图和列表视图的切换按钮**/
                cardView: false,                    	/**是否显示详细视图**/
                detailView: false,                  	/**是否显示父子表**/
                columns: [
                    {checkbox: true},
                    {field: 'Number', title: '编号',align: 'center',valign: 'middle',width:'50px',
                        formatter: function (value, row, index) {
                            var page = $tt.bootstrapTable("getPage");
                            return page.pageSize * (page.pageNumber - 1) + index + 1;
                        }
                    },
                    {field: 'loginName',title: '会员名称',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            var  a_html = '<a data-toggle="modal" data-target="#detailModal" href="#" mce_href="#" onclick="detailInfo('+row.customerId+')">' + value + '</a>';
                            return a_html;
                        }
                    },
                    {field: 'sex',title: '性别',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){  //function里面的三个参数代表当前字段值，当前行数据对象，行号（行号从0开始）
							var sexStr = "-";
                            <c:forEach items="${redis:getBasicKeyBook('sex')}" var="kb">
                            if(value=="${kb.value}"){
                                sexStr="${kb.name}";
                            }
                            </c:forEach>
                            return sexStr;
                        }
					},
                    {field: 'phone',title: '手机号',align: 'center',valign: 'middle'},
                    {field: 'email',title: '电子邮箱',align: 'center',valign: 'middle'},
                    {field: 'lockedState',title: '冻结状态',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value=="0"){ return "<font class='color_001'>未冻结</font>";}
                            if(value=="1"){ return "<font class='color_002'>已冻结</font>";}
                        }
                    },
                    {field: 'type',title: '会员类型',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value=="1"){ return "普通用户";}
                            if(value=="2"){ return "供应商店铺";}
                        }
                    },
                    {field: 'wxUserOpenId',title: '是否关联微信',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value!=null&&value!=''){ return '<a data-toggle="modal" data-target="#detailWxFansUserInfo" href="#" mce_href="#" onclick="detailWxFansUserInfo('+row.customerId+')">' + '<font class="color_001">已关联</font>' + '</a>';}
                            else{ return "<font class='color_002'>未关联</font>";}
                        }
                    },
                    {field: 'registerIp',title: '注册IP',align: 'center',valign: 'middle'},
                    {field: 'registerDate',title: '注册时间',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            return  toJsonDate(value,"yyyy-MM-dd hh:mm:ss");
                        }
                    }
                ],
                queryParams: function (params) {
                    /**特别说明，返回的参数的值为空，则当前参数不会发送到服务器端,这种指定请求参数的方式和datatables控价类似**/
                    params.loginName = $("#q_loginName").val();
                    params.phone = $("#q_phone").val();
                    params.email = $("#q_email").val();
                    params.lockedState = $("#q_lockedState").val();
                    params.wxUserOpenId = $("#q_wxUserOpenId").val();
                    params.currentPage = params.pageNumber;
                    return params;
                }
            });
        });

        /**
         * 充值明细
         */
		<shiro:hasPermission name="back_gotoCustomerPage_rechargeSheet">
        function rechargeSheetInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/customer/gotoRechargePage.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**
         * 金币明细
         */
		<shiro:hasPermission name="back_gotoCustomerPage_coinSheet">
        function coinSheetInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/customer/gotoCustomerMallCoinPage.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**
         * 查询分销员
         */
		<shiro:hasPermission name="back_gotoCustomerPage_queryLowe">
        function queryLoweInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/disCustomer/gotoLowePage.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**
         * 商品收藏
         */
		<shiro:hasPermission name="back_gotoCustomerPage_productCollect">
        function productCollectInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/customerCollectProduct/findCustomerCollectProductListByCustomerId.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**
         * 店铺收藏
         */
		<shiro:hasPermission name="back_gotoCustomerPage_shopCollect">
        function shopCollectInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/customerCollectProduct/findCustomerCollectShopInfoListByCustomerId.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>

        /**
         * 收货地址
         */
		<shiro:hasPermission name="back_gotoCustomerPage_address">
        function addressInfo() {
            /**获取选中行的id**/
            var selectedRow = $("#tt").bootstrapTable('getSelections');
            if (selectedRow.length == 1) {
                location.href="${basePath}/back/customerAcceptAddress/findAcceptAddressListByCustomerId.inhtm?customerId="+selectedRow[0].customerId;
            } else {
                showMsg("请选择一行记录！");
            }
        }
		</shiro:hasPermission>
	</script>
</head>
<body>
<div class="panel-body" id="customer-main-panel">
	<!-- 查询条件 -->
	<div class="panel panel-default">
		<div class="panel-heading">会员信息查询</div>
		<div class="panel-body">
			<form id="qform" class="form-horizontal">
				<div class="form-group" style="margin-top:15px">
					<div class="col-sm-3" >
						<div class="input-group input-group-sm">
							<span class="input-group-addon">会员名称</span>
							<input type="text" class="form-control" id="q_loginName" name="loginName" placeholder="请输入会员名称"/>
						</div>
					</div>
					<div class="col-sm-2" style="width: 200px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">手机号</span>
							<input type="text" class="form-control" id="q_phone" name="phone" placeholder="请输入手机号"/>
						</div>
					</div>
					<div class="col-sm-2" style="width: 200px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">邮箱</span>
							<input type="text" class="form-control" id="q_email" name="email" placeholder="请输入邮箱"/>
						</div>
					</div>
					<div class="col-sm-2" style="width: 160px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">状态</span>
							<select id="q_lockedState" class="form-control">
								<option value="">请选择</option>
								<option value="0">未冻结</option>
								<option value="1">已冻结</option>
							</select>
						</div>
					</div>
					<div class="col-sm-2" style="width: 220px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">是否关联微信</span>
							<select id="q_wxUserOpenId" class="form-control">
								<option value="">请选择</option>
								<option value="0">未关联</option>
								<option value="1">已关联</option>
							</select>
						</div>
					</div>
					<div class="col-sm-2">
						<button type="button" id="btn_query" class="btn btn-primary">查询</button>&nbsp;&nbsp;
						<button type="reset" class="btn btn-success" id="resetBtn">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>

	<!-- 工具栏 -->
	<div id="toolbar" class="btn-group">
		<shiro:hasPermission name="back_gotoCustomerPage_freeze">
			<button id="btn_freeze" type="button" class="btn btn-default" data-toggle="modal" onclick="freezeInfo()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>冻结操作
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_recharge">
			<button id="btn_recharge" type="button" class="btn btn-default" data-toggle="modal" onclick="rechargeInfo()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>会员余额充值
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_rechargeSheet">
			<button id="btn_rechargeSheet" type="button" class="btn btn-default" onclick="rechargeSheetInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>充值明细
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_coinSheet">
			<button id="btn_coinSheet" type="button" class="btn btn-default" onclick="coinSheetInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>金币明细
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_queryLowe">
			<button id="btn_queryLowe" type="button" class="btn btn-default" onclick="queryLoweInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询推广员
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_productCollect">
			<button id="btn_productCollect" type="button" class="btn btn-default" onclick="productCollectInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>商品收藏
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_shopCollect">
			<button id="btn_shopCollect" type="button" class="btn btn-default" onclick="shopCollectInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>店铺收藏
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_address">
			<button id="btn_address" type="button" class="btn btn-default" onclick="addressInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>收货地址
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoCustomerPage_invoice">
			<button id="btn_invoice" type="button" class="btn btn-default" data-toggle="modal" onclick="invoiceInfo()">
				<span class="glyphicon glyphicon-search" aria-hidden="true"></span>发票信息
			</button>
		</shiro:hasPermission>

		<%--待完善功能--%>
		<%--<shiro:hasPermission name="back_gotoCustomerPage_upgradeShop">
			<button id="btn_upgradeShop" type="button" class="btn btn-default" data-toggle="modal" onclick="upgradeShop">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>升级为店铺
			</button>
		</shiro:hasPermission>
		<shiro:hasPermission name="back_gotoCustomerPage_bindingLast">
			<button id="btn_" type="button" class="btn btn-default" data-toggle="modal" onclick="bindingLast">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>绑定上级推广商
			</button>
		</shiro:hasPermission>--%>
	</div>

	<!-- 渲染的table -->
	<table id="tt"></table>

	<!-- 详情页面 -->
	<jsp:include page="detail.jsp"/>
	<!-- 冻结操作页面 -->
	<jsp:include page="congeal.jsp"/>
	<!-- 会员余额充值页面 -->
	<jsp:include page="recharge.jsp"/>
	<!-- 授信额度管理 -->
	<%--<jsp:include page="lineOfCredit.jsp"/>--%>
	<!-- 粉丝信息 -->
	<jsp:include page="detailWxFansUserInfo.jsp"/>
	<!-- 发票信息 -->
	<jsp:include page="invoiceInfo.jsp"/>
</div>

</body>
</html>
